package com.zhuiyi.yiqingbackend.controller;

import com.zhuiyi.yiqingbackend.common.BaseResponse;
import com.zhuiyi.yiqingbackend.common.ResultUtils;
import com.zhuiyi.yiqingbackend.domain.User;
import com.zhuiyi.yiqingbackend.domain.request.LoginRequest;
import com.zhuiyi.yiqingbackend.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/login")
    public BaseResponse<User> login(@RequestBody LoginRequest loginRequest) {
        User user = userService.login(loginRequest);
        return ResultUtils.success(user);
    }
}
